//
//  AlbumPhotoPicker.m
//  PhotoPicker
//
//  Created by 为为 on 13-3-13.
//  Copyright (c) 2013年 为为. All rights reserved.
//

#import "AlbumPhotoPicker.h"
#import "UIImage+Resize.h"
#import "MBProgressHUD.h"

@implementation AlbumPhotoPicker

- (id)init
{
	if(self=[super init])
	{
		
	}
	return self;
} 

- (void)pickAlbum
{
	self.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
	self.delegate = self;
    [self.controller presentViewController:self animated:YES completion:nil];
}

- (void)pickCamera
{
	if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
		self.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
	} else {
		self.sourceType = UIImagePickerControllerSourceTypeCamera;
	}
	self.delegate = self;
    [self.controller presentViewController:self animated:YES completion:nil];
}

#pragma mark Image Picker

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
	if (self.finishBlock) {
        [self.controller dismissViewControllerAnimated:YES completion:^{
            self.finishBlock(self, info);
        }];
	}
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self.controller dismissViewControllerAnimated:YES completion:nil];
}

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
	
}

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
	
}

@end
